<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    let obj= {
        key1: 'value1',
        key2: 'value2',
        key3: 'value3',
        key4: 'value4'
    }


    //方法一
    for(let key  in obj){
        console.log(key + '---' + obj[key])
    }


    //方法二
    console.log(Object.keys(obj)); // ["key1", "key2", "key3", "key4"]

    console.log(Object.values(obj))  //["value1", "value2", "value3", "value4"]

    let aaa=Object.keys(obj).filter(function (x){
        console.log(x+'----'+obj[x])
    })




    //方法三
    Object.getOwnPropertyNames(obj).forEach(function(key){
        console.log(key+ '****'+obj[key])
    })


</script>
</body>
</html>